<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored="false" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ include file="top.jsp"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <base href="${basePath}">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="css/common.css" rel="stylesheet" type="text/css" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
    <script src="./js/jquery-1.8.3.js" type="text/javascript"></script>
</head>

<body>
<div class="wrap">
<!-- main begin-->
  <div class="sale">
    <h1 class="lf">在线拍卖系统</h1>
    <div class="logout right"><a href="#" title="注销">注销</a></div>
  </div>

    <div class="forms" >
        <form action="do/auction/search" method="post">

            <label for="name">名称</label>
            <input name="name" type="text" class="nwinput" id="name"/>

            <label for="names">描述</label>
            <input name="desc" type="text" id="names" class="nwinput"/>

            <label for="time">开始时间</label>
            <input name="start" type="text" id="time" class="nwinput"/>

            <label for="end-time">结束时间</label>
            <input name="end" type="text" id="end-time" class="nwinput" />

            <label for="price">起拍价</label>
            <input name="price" type="text" id="price" class="nwinput" />
            <input  name="" type="submit"  value="查询" class="spbg buttombg f14  sale-buttom"/>
            <input type=""   value="发布" class="spbg buttombg f14  sale-buttom buttomb" onclick="redirectToPage()"/>
        </form>
    </div>


  <div class="items">
      <ul class="rows even strong">
        <li>名称</li>
        <li class="list-wd">描述</li>
        <li>开始时间</li>
        <li>结束时间</li>
        <li>起拍价</li>
        <li class="borderno">操作</li>
      </ul>

      <c:forEach var="auction" items="${count}">
          <ul class="rows">
              <li><a href="国书" title="">${auction.auctionname}</a></li>
              <li class="list-wd">${auction.auctiondesc}</li>
              <li><fmt:formatDate value="${auction.auctionstarttime}" pattern="yyyy-MM-dd HH:mm:ss"/></li>
              <li><fmt:formatDate value="${auction.auctionendtime}" pattern="yyyy-MM-dd HH:mm:ss"/></li>
              <li>${auction.auctionstartprice}</li>
              <li class="borderno red">
                  <a href="do/auction/update?auctionid=${auction.auctionid}" title="竞拍" >修改</a>|
                  <a href="#" title="竞拍" onclick="del(this,${auction.auctionid});">删除</a>
              </li>
          </ul>
      </c:forEach>
      <div class="page">
          <form action="do/auction/homeAdmin" method="get">
              <a href="do/auction/homeAdmin?page=1" title="首页">首页</a>
              <a href="do/auction/homeAdmin?page=${prevPage}" title="上一页">上一页</a>
              <!-- 显示页码链接，这里需要后端动态生成 -->
              <input  name="page" value="${currentPage}">
              <input type="submit" value="Go">
              <span>共${totalPages}页</span>
              <!-- 使用普通的链接而不是表单提交，以避免不必要的重定向 -->
              <a href="do/auction/homeAdmin?page=${nextPage}" title="下一页">下一页</a>
              <a href="do/auction/homeAdmin?page=${totalPages}" title="尾页">尾页</a>
          </form>
      </div>
  </div>
  <script>
      function del(obj,auctionid) {
          var result =confirm("你确认要删除吗？")
          if(result){
              alert(auctionid)
              $.getJSON("do/auction/delete",{id:auctionid},function (data){
                  if(data>0){
                      alert("删除成功！")
                      $(obj).parent().parent().remove();
                      location.reload(); // 重新加载当前页面
                  }else {
                      alert("删除失败")
                  }
              })
          }
      };

	   function update(obj,auction){
           var result =confirm("你确认要修改吗？")
           if(result){
               alert(auctionid)
               $.getJSON("do/auction/update",{action:auction},function (data){
                   if(data>0){
                       alert("修改成功！")

                   }else {
                       alert("修改失败")
                   }
               })
           }
		   }


      function redirectToPage() {
          // 替换 'page_url_here' 为你要跳转的页面 URL
          window.location.href = 'do/auction/addAuction';
      }
  </script>
<!-- main end-->
</div>
</body>
</html>
